# Contributor: Nicolas Lorin <androw95220@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=scons
pkgver=4.8.1
pkgrel=0
pkgdesc="Software construction system"
url="https://scons.org/"
arch="noarch"
license="MIT"
depends="python3"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="xz"
subpackages="$pkgname-pyc $pkgname-doc"
# fetching both sources, because only github tarball has tests
# and only sourceforge tarball has prebuilt manpages
# building the scons manpages requires working scons install...
source="https://github.com/SCons/scons/archive/$pkgver/scons-$pkgver.tar.gz
	https://downloads.sourceforge.net/project/scons/scons/$pkgver/SCons-$pkgver.tar.gz
	"

# tests need py3-psutil from community
options="!check"

prepare() {
	default_prepare

	# remove failing test
	case $CARCH in
	ppc64le) rm test/builderrors.py ;;
	esac
}

build() {
	gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 runtest.py -a
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	# find and remove directories containing docbook files
	find "$pkgdir" -name 'docbook' -type d -exec rm -rf {} +

	install -Dm644 scons.1 scons-time.1 sconsign.1 \
		-t "$pkgdir"/usr/share/man/man1/
}

sha512sums="
b9f39634b36876fa15e2db968a38693745ce3f0f14e838e97f69e2a6762d8f78c04e52843e2ce50900000833854c90ee2bd9d3d84bb48d9acfbf41f94af02775  scons-4.8.1.tar.gz
dad76d7f16b4cc1d9e25c9d8969773604e23accbb4e94451f0fc725919bf223cf04265f5d2b64a1b7e96cc63496cba574df3a634fd6779f2eb5fb7246fded120  SCons-4.8.1.tar.gz
"
